;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; HW6 blocks world + painting (stub)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define (domain hw6)
  (:requirements :strips)

  (:constants 
	red
	blue
	green
	
	)
	
  (:predicates 
	(on ?x ?y)
	(on-table ?x)
	(clear ?x)
	(arm-empty)
	(holding ?x)
	(color ?x ?c)
	(clean ?x)
	(paint ?x ?c)
	(brush ?x)
	  )	 

 (:action stack
	     :parameters (?sob ?sunderob)
	     :precondition (and (holding ?sob) (clear ?sunderob))
	     :effect
	     (and (not (holding ?sob))
		   (not (clear ?sunderob))
		   (clear ?sob)
		   (arm-empty)
		   (on ?sob ?sunderob)))
		   
(:action unstack
	     :parameters (?blockB ?blockA)
	     :precondition (and (on ?blockB ?blockA) (clear ?blockB) (arm-empty))
	     :effect
	     (and (holding ?blockB)
		   (clear ?blockA)
		   (not (clear ?blockB))
		   (not (arm-empty))
		   (not (on ?blockB ?blockA))))

(:action load-brush-with-color
	     :parameters (?brush ?can ?blue)
	     :precondition ( and (holding ?brush)
			(clean ?brush)
			(paint ?can ?blue)
			(on-table ?can)
			)
	     :effect
	     (and (color ?brush  ?blue)
				(Not(clean ?brush))))
		 
(:action brush-paint
	     :parameters (?brush ?blockA ?blue)
	     :precondition ( and (holding ?brush)
						(on-table ?blockA)
						;(clear ?blockA)
						(Not(clean ?brush))
						(color ?brush ?blue)
						(not(brush ?blockA))
				)
	     :effect
	     (and (color ?blockA  ?blue)))
		 
(:action spray-paint
	     :parameters (?blockB ?sprayerRed  ?red )
	     :precondition ( and (holding ?sprayerRed)
						(on-table ?blockB)
						(color ?sprayerRed  red)
						;(color ?red  red)
						;(block ?blockB)
						(not(brush ?blockB))
						(not(brush ?sprayerRed))
						;(sprayer ?sprayerRed)
						)
	     :effect
	     (and (color ?blockB  ?red)))

	   	
 
(:action put-down
 	     :parameters (?obj1 )
 	     :precondition (and (holding ?obj1) (not(arm-empty)))
 	     :effect
 	     (and (not (holding ?obj1))
 		   (arm-empty)
 		   (clear ?obj1)
 		   (on-table ?obj1)))
 
(:action pickup
 	     :parameters (?obj)
 	     :precondition (and (on-table ?obj)
 						(clear ?obj)
 						(arm-empty))
 	     :effect
 	     (and (holding ?obj)
 		   (not(arm-empty))
 		   (not (clear ?obj))
 		   (not(on-table ?obj))))) 
